package cn.scm.server.multistage.service.impl;

import cn.scm.server.multistage.dao.BizCustomerLimitDao;
import cn.scm.server.multistage.entity.BizCustomerLimit;
import cn.scm.server.multistage.service.BizCustomerLimitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户额度表(BizCustomerLimit)表服务实现类
 *
 * @author makejava
 * @since 2020-09-23 20:52:21
 */
@Service("bizCustomerLimitService")
public class BizCustomerLimitServiceImpl implements BizCustomerLimitService {
    @Resource
    private BizCustomerLimitDao bizCustomerLimitDao;

    /**
     * 通过ID查询单条数据
     *
     * @param customerLimitId 主键
     * @return 实例对象
     */
    @Override
    public BizCustomerLimit queryById(String customerLimitId) {
        return this.bizCustomerLimitDao.queryById(customerLimitId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BizCustomerLimit> queryAllByLimit(int offset, int limit) {
        return this.bizCustomerLimitDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param bizCustomerLimit 实例对象
     * @return 实例对象
     */
    @Override
    public BizCustomerLimit insert(BizCustomerLimit bizCustomerLimit) {
        this.bizCustomerLimitDao.insert(bizCustomerLimit);
        return bizCustomerLimit;
    }

    /**
     * 修改数据
     *
     * @param bizCustomerLimit 实例对象
     * @return 实例对象
     */
    @Override
    public BizCustomerLimit update(BizCustomerLimit bizCustomerLimit) {
        this.bizCustomerLimitDao.update(bizCustomerLimit);
        return this.queryById(bizCustomerLimit.getCustomerLimitId());
    }

    /**
     * 通过主键删除数据
     *
     * @param customerLimitId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String customerLimitId) {
        return this.bizCustomerLimitDao.deleteById(customerLimitId) > 0;
    }
}